#define DEBUG
#include <cstdio>
#define HASHES 40000003
#define MAXN 14

using namespace std;

class Hash {
public:
  unsigned long long key[HASHES+1];
  int val[HASHES+1];
  bool book[HASHES+1];

  void add(unsigned long long k, int v) {
    int p = k%HASHES;
    for (; book[p]; p=(p+1)%HASHES) {
      if (key[p]==k) {
	break;
      }
    }
    book[p] = true, key[p] = k, val[p] += v;
  }

  int get(unsigned long long k) {
    int p = k%HASHES;
    for (; book[p]; p=(p+1)%HASHES) {
      if (key[p]==k) {
	return val[p];
      }
    }
    return 0;
  }
};

unsigned long long hash(int a, int b, int c) {
  return ((a*100000+b)*10000000000+c);
}

int solve(int o, int p, int s, int l, bool flag, int t, int n, int a[MAXN+1][MAXN+1], int tl) {
  static Hash f;
  if (o==t) {
    if (flag) {
      return f.get(hash(p, (1<<n)-s+(1<<(p-1)), tl-l));
    } else {
      f.add(hash(p, s, l), 1);
      return 0;
    }
  } else {
    int ret=0;
    for (int i=1; i<=n; i++) {
      if (!((s>>(i-1))&1)) {
	ret += solve(o+1, i, s|(1<<(i-1)), l+a[p][i], flag, t, n, a, tl);
      }
    }
    return ret;
  }
}

int main() {
  freopen("way.in", "r", stdin);
  freopen("way.out", "w", stdout);

  static int a[MAXN+1][MAXN+1];
  int n, l;
  scanf("%d %d", &n, &l);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  solve(0, 1, 1, 0, false, n/2, n, a, l);
  printf("%d\n", solve(0, 1, 1, 0, true, n/2+n%2, n, a, l));

  fcloseall();
  return 0;
}
